import java.util.Stack;

class Demo {
    public int evalRPN(String[] tokens){
        Stack<Integer> stack = new Stack<>();
        for (String x : tokens){
            //不是加减乘除
            if (!isOperation(x)){
                stack.push(Integer.parseInt(x));
            }else{
                int num1 = stack.pop();
                int num2 = stack.pop();
                switch (x){
                    case "+":
                        stack.push(num1+num2);
                        break;
                    case "-":
                        stack.push(num1-num2);
                        break;
                    case "*":
                        stack.push(num1*num2);
                        break;
                    case "/":
                        stack.push(num1/num2);
                        break;
                }
            }
        }
        return stack.pop();
    }
    private boolean isOperation(String opera){
        if(opera.equals("+") || opera.equals("-") || opera.equals("*") || opera.equals("/")){
            return true;
        }
        return false;
    }
}
